# coding: utf-8
# Project：PyCharmMiscProject
# File：计算器.py
# Author：liuchuanzhi
# Date ：2025/3/26 19:25
# IDE：PyCharm
import math


def Csum(num1,num2):
    return num1+num2
def Csub(num1,num2):
    return num1-num2
def Cmulti(num1,num2):
    return num1*num2
def Cdiv(num1,num2):
    if num2==0:
        print("除数不能为零")
        return 0
    return num1/num2
def Clogab(a,b):
    return math.log(a,b)
def Cre(num1,num2):
    return num1%num2
def Cpow(num1,num2):
    return math.pow(num1,num2)


flag=True
while flag:
    if input("请问需要复数（1）还是整数（2）运算：")=="1":
        num1=complex(input("请输入一个复数："))
        num2=complex(input("请输入另一个复数："))
    else:
        num1=int(input("请输入一个数字: "))
        num2=int(input("请输入另一个数字: "))
    choice=input("请输入运算符(+,-,*,/,log,%,pow):")

    if choice=="+":
        print("num1",choice,"num2=",Csum(num1,num2))
    elif choice=="-":
        print("num1",choice,"num2=",Csub(num1,num2))
    elif choice=="*":
        print("num1",choice,"num2=",Cmulti(num1,num2))
    elif choice=="/":
        print("num1",choice,"num2=",Cdiv(num1,num2))
    elif choice == "log":
        print(num1,"以",num2,"为基底的对数=", Clogab(num1, num2))
    elif choice=="%":
        print(num1,"对",num2,"取余是",Cre(num1,num2))
    elif choice=="pow":
        print(num1,"的",num2,"次幂是",Cpow(num1,num2))

    con= input("是否继续？Y/N\n")
    if con =="Y" or con=="y":
        flag = True
    else:
        flag = False

